package com.bitmain.mmst.miner.monitor.executor;

import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;

import com.bitmain.mmst.domain.MinerNetworkMessage;

/**
 * 
 *
 * @author Richard - rui.wu@bitmain.com
 * @since 2016年7月5日
 *
 */
public class MinerNetworkExecutor extends AbstractMinerExecutor<MinerNetworkExecutor,MinerNetworkMessage>{


	private MinerNetworkMessage message;
	
	public MinerNetworkExecutor(MinerNetworkMessage message) {
		super(MinerNetworkExecutor.class);
		this.message = message;
	}

	@Override
	public MinerNetworkMessage execute() {
		String ip = message.getHost();
		String mac = "";
		
		//测试用
		
		
		if(BooleanUtils.isTrue(pingMiner(message.getHost()))){
			message.setPingable(true);
			mac = getMinerMac(ip);
			if(StringUtils.isNotEmpty(mac)){
				System.out.println("【当前检测ip】"+ ip +"，获取到mac地址");
				message.setMac(mac);
				message.setMacable(true);
			}
		}else{
			//System.out.println("【当前检测ip】"+ ip +"，检测结果为:失败");
			message.setPingable(false);
			message.setMacable(false);
		}
		
		return message;
	}

}
